/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import {Form, Input, Radio, Select,   Icon,
  Upload, } from 'antd';
import {connect} from 'dva';
import moment from 'moment'
import request from '@/utils/request';
const FormItem = Form.Item;
const { TextArea } = Input;
const RadioGroup = Radio.Group;
const Option = Select.Option;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      users:[]
    };
  }

  componentDidMount() {
    const that=this;
  }
  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 6},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 15},
      }
    };

    const {getFieldDecorator} = this.props.form;
    return (
      <div>

        <Form onSubmit={this.handleSubmit}>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               供应商
            </span>
            )}
          >
            {getFieldDecorator('supplier_id', {
              initialValue: this.props.editRecord?this.props.editRecord.supplier_id:"",
              rules: [{ required: true, message: '请选择供应商' }],
            })(
              <Select  >
                {
                  this.props.all_suppliers.map((item,index)=>{
                    return <Option title={item.name} key={index} value={item.id}>{item.name}</Option>
                  })
                }
              </Select>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               材料名称
            </span>
            )}
          >
            {getFieldDecorator('name', {
              initialValue: this.props.editRecord?this.props.editRecord.name:"",
              rules: [{ required: true, message: '请输入材料名称' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               分类
            </span>
            )}
          >
            {getFieldDecorator('type', {
              initialValue: this.props.editRecord?this.props.editRecord.type:"",
              rules: [{ required: true, message: '请输入材料名称' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               型号
            </span>
            )}
          >
            {getFieldDecorator('model', {
              initialValue: this.props.editRecord?this.props.editRecord.model:"",
              rules: [{ required: true, message: '请输入材料名称' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               单位
            </span>
            )}
          >
            {getFieldDecorator('unit', {
              initialValue: this.props.editRecord?this.props.editRecord.unit:"",
              rules: [{ required: true, message: '请输入材料名称' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               备注
            </span>
            )}
          >
            {getFieldDecorator('remark', {
              initialValue: this.props.editRecord?this.props.editRecord.remark:"",
            })(
              <Input />
            )}
          </FormItem>
        </Form>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);


